package servicios;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;


public class Transaccion {
    private EntityManagerFactory entityManagerFactory;
    private EntityManager entityManager;
    private EntityTransaction entityTransaction;

    public Transaccion() {
        
        super();
        System.out.println("2");
        this.setEntityManagerFactory(Persistence.createEntityManagerFactory("STAPU"));
        System.out.println("3");
        this.setEntityManager(entityManagerFactory.createEntityManager());
        System.out.println("4");
        this.setEntityTransaction(entityManager.getTransaction());
        System.out.println("5");
    }

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }

    public EntityManager getEntityManager() {
        return entityManager;
    }

    public void setEntityTransaction(EntityTransaction userTransaction) {
        this.entityTransaction = userTransaction;
    }

    public EntityTransaction getEntityTransaction() {
        return entityTransaction;
    }

    public void setEntityManagerFactory(EntityManagerFactory entityManagerFactory) {
        this.entityManagerFactory = entityManagerFactory;
    }

    public EntityManagerFactory getEntityManagerFactory() {
        return entityManagerFactory;
    }
}